let path = require("path");
// 引入html-webpack-plugin
const HtmlWebpackPlugin = require('html-webpack-plugin');
// 实例化插件
let HtmlPlugin = new HtmlWebpackPlugin({
    // 打包后的html文件名称
    filename:"home.html",
    // 要打包的html模板
    template:path.resolve(__dirname,"public/index.html")
});
module.exports = {
    mode:"development",
    entry:"./src/index.js",
    output:{
        filename:"build.js",
        path:path.resolve(__dirname,"dist")
    },
    module:{
        // 添加文件打包规则 rules规则
        rules:[
            {
                test:/\.css$/i,
                use:["style-loader","css-loader"]
            },
            {
                test: /\.(png|svg|jpg|jpeg|gif)$/i,
                type: 'asset/resource',
              }
        ]
    },
    // 注册插件
    plugins:[HtmlPlugin]
}